<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

Route::get('/', function () {
	return view('welcome');
});

Route::get('ID/{id}', function ($id) {
	echo 'ID:' . $id;
});

Route::get('/user/{name?}', function ($name = 'zxx') {
	echo 'name:' . $name;
});

Route::get('/role', [
	'middleware' => 'role:editor',
	'uses' => 'TestController@index',
]);

Route::get('/zindex', 'ZindexController@index');

Route::get('/zindex1', [
	'middleware' => 'role:test',
	'uses' => 'ZindexController@index',
]);

Route::get('/zdemo', [
	'middleware' => 'role:demo',
	'uses' => 'ZdemoController@index',
]);

Route::get('/url', 'UriController@reqtest');

Route::get('/thisreq', 'UriController@thisreq');

/*使用any可以匹配全部的http方法*/
Route::any('/input', 'UriController@inputtest');
/*使用match可以指定方法*/
Route::match(['get', 'post'], '/inputest', 'UriController@inputtest');

Route::get("/reg", "UriController@reg");
Route::post('/user/register', 'UriController@register');

Route::any('/cookie', 'CookieController@index');

Route::any('/getcookie', 'CookieController@getcookie');

Route::get('/basic_request', function () {
	// return "hello basic_request";
	//
	// return response("basic_request", 200)
	// ->header('Content-Type', 'text/html')
	// ->header('X-Header-One', 'Header Value');
	//
	return response()->json(["test" => 1]);
});

Route::get('/insert','StdInsertController@insertform');
Route::post('/create','StdInsertController@insert');//update
Route::get('/update','StdInsertController@update');//


Route::get("/ajax",function(){
	return view("message");
});

Route::any("/getmsg","AjaxController@index");

Route::any('/facadeex',function(){
	return TestFacades::testingFacades();
});

Route::get('/event',function(){
	echo "event";

	$name = "ok";
	event(new App\Events\StudentAdded($name));
});

Route::get('/eventtest','EventController@event');